package com.yanqu.road.server.cmd.player;

import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.pb.manor.FishPondProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/10/20 15:59
 */
@Cmd(code = CrossProtocol.C_CROSS_VISIT_PLAYER_FISH_POND, desc = "跨服拜访其他玩家鱼塘")
public class CrossVisitPlayerFishPondCmd extends CrossCommand {
    private long otherPlayerId;
    private long otherPlayerServerId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        FishPondProto.VisitOtherFishPondReqMsg msg = FishPondProto.VisitOtherFishPondReqMsg.parseFrom(packet.getBytes());
        otherPlayerId = msg.getPlayerId();
        otherPlayerServerId = msg.getServerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        FishPondProto.CrossVisitOtherFishPondReqMsg.Builder reqMsg = FishPondProto.CrossVisitOtherFishPondReqMsg.newBuilder();
        reqMsg.setOriginPlayerId(packet.getPlayerId());
        reqMsg.setOriginServerId(serverId);
        reqMsg.setVisitPlayerId(otherPlayerId);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_FISH_POND_CROSS_VISIT_FISH_POND, reqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
